<template>
  <ContentDetailWrap :title="t('warehouse.add')">
    <template #header>
      <BaseButton @click="go(-1)">
        {{ t('common.back') }}
      </BaseButton>
    </template>
    <!-- 表单 -->
    <el-collapse-transition>
      <el-descriptions border :column="2" abel-align="left" content-align="left">
        <el-descriptions-item :label="t('category.parent_id')" width="25%">
          {{ state.currentRow?.parentName }}
        </el-descriptions-item>
        <el-descriptions-item :label="t('category.name')" width="25%">
          {{ state.currentRow?.name }}
        </el-descriptions-item>

        <el-descriptions-item :label="t('category.description')" width="25%">
          {{ state.currentRow?.description }}
        </el-descriptions-item>

        <el-descriptions-item :label="t('category.image')" width="25%">
          <FileList :files="state.currentRow?.imageInfo || []" />
        </el-descriptions-item>

        <el-descriptions-item :label="t('category.sort_order')" width="25%">
          {{ state.currentRow?.sort_order }}
        </el-descriptions-item>

        <el-descriptions-item :label="t('category.solution_type')" width="25%">
          {{ state.currentRow?.solution_type === 1 ? '是' : '否' }}
        </el-descriptions-item>

        <el-descriptions-item :label="t('category.creator')" width="25%">
          {{ state.currentRow?.create_name }}
        </el-descriptions-item>

        <el-descriptions-item :label="t('category.create_time')" width="25%">
          {{ state.currentRow?.create_time }}
        </el-descriptions-item>

        <el-descriptions-item :label="t('category.updater')" width="25%">
          {{ state.currentRow?.update_name }}
        </el-descriptions-item>

        <el-descriptions-item :label="t('category.update_time')" width="25%">
          {{ state.currentRow?.update_time }}
        </el-descriptions-item>
      </el-descriptions>
    </el-collapse-transition>
  </ContentDetailWrap>
</template>

<script setup lang="tsx">
import { ref, reactive } from 'vue'
import { CurdData } from '@/api/category/types'
import { getInfoApi } from '@/api/category'
import { useI18n } from '@/hooks/web/useI18n'
import { useRouter, useRoute } from 'vue-router'
import FileList from '@/components/FilePreview/index.vue' // 引入 FilePreview 组件

const { push, go } = useRouter()
const { t } = useI18n()

const isLoading = ref(true)

const { query } = useRoute()

const state = reactive({
  currentRow: null as Nullable<CurdData>
})

const fetchData = async () => {
  const resp = await getInfoApi(query.id as string)
  state.currentRow = resp.data
  isLoading.value = false
}

fetchData()
</script>

<style lang="less" scoped>
.header {
  display: flex;
  height: 40px;
  padding: 0 10px;
  margin-bottom: 10px;
  font-weight: 900;
  background-color: #f3f3f3;
  border-radius: 5px;
  align-items: center;
  justify-content: space-between;
}

:deep(.el-form-item__label) {
  padding: 8px 11px;
  text-align: left !important;
  justify-content: left !important;
}
</style>
